package com.alpha.traitdunion2;

import java.util.ArrayList;





import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
//import android.database.Cursor;
//import android.net.Uri;
import android.os.Bundle;
//import android.view.Menu;
//import android.view.MenuItem;
//import android.provider.ContactsContract;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
//import android.provider.ContactsContract.Contacts.Data;
@SuppressLint("ParserError")
public class Xrima extends Activity {
    /** Called when the activity is first created. */
	
	private GridviewAdapter mAdapter;
	private ArrayList<String> listCountry;
	private ArrayList<Integer> listFlag;
	//private static final int PICK_CONTACT = 3;
	private GridView gridView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.xrima1);
        
        prepareList();
        
        // prepared arraylist and passed it to the Adapter class
        mAdapter = new GridviewAdapter(this,listCountry, listFlag);
        
        // Set custom adapter to gridview
        gridView = (GridView) findViewById(R.id.gridView1);
        gridView.setAdapter(mAdapter);
        
        // Implement On Item click listener
        gridView.setOnItemClickListener(new OnItemClickListener() 
        {
			public void onItemClick(AdapterView<?> arg0, View arg1, int position,
					long arg3) {
				Toast.makeText(Xrima.this, mAdapter.getItem(position), Toast.LENGTH_SHORT).show();
				if(position == 0){
					Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://europa.eu/index_el.htm"));
        	        startActivity(browserIntent);
		       			}
				if(position == 1){
					Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.espa.gr/"));
        	        startActivity(browserIntent);
				
				}
				if(position == 2){
					Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.ktpae.gr/"));
        	        startActivity(browserIntent);
					
					
					{}}
				if(position == 3){
					Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.digitalplan.gov.gr/"));
        	        startActivity(browserIntent);
					
					
					}
				

			} 
		});
        
    }
   
   
    
    public void prepareList()
    {
    	  listCountry = new ArrayList<String>();
    	  
    	  listCountry.add("Ευρωπαϊκή Ένωση");
    	  listCountry.add("ΕΣΠΑ 2007-2013");
          listCountry.add("ΚτΠ ΑΕ");
          listCountry.add("Ψηφιακή Σύγκλιση");
          //listCountry.add("Î‘Î³Î±Ï€Î·Î¼Î­Î½Î±");
          //listCountry.add("ÎšÎ±Î»Î¬Î¸Î¹");
          
          
          listFlag = new ArrayList<Integer>();
          listFlag.add(R.drawable.ee);
          listFlag.add(R.drawable.espa);
          listFlag.add(R.drawable.koinonia);
          listFlag.add(R.drawable.psifiaki);
          //listFlag.add(R.drawable.favorite);
          //listFlag.add(R.drawable.cart);
        
    }
   

/*@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_question, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
	
    if (item.getItemId()==R.id.menu_settings) {
    
       startActivity ( new Intent (GridViewExampleActivity.this, Calendari.class) );
       
            return true;
}
    return super.onOptionsItemSelected(item);
}*/
}
